#!/usr/bin/env python
"测试os.spawnv"

import os
import sys


def main():
	platform_str = sys.platform
	py_path_str = sys.executable

	if platform_str[:3] == 'win':
		for i_id_int in range(10):
			pid_int = os.spawnv(
				os.P_NOWAIT, py_path_str, ('python', 'child.py', str(i_id_int))
			)
			print('Process {} spawned'.format(pid_int))
	else:
		for i_id_int in range(10):
			pid_int = os.fork()

			if pid_int:
				print('Process {} spawned'.format(pid_int))
			else:
				os.execlp('python', 'python', 'child.py', str(i_id_int))

	print('Main process exit')


if __name__ == '__main__':
	main()
